package ink.lovejinhu.leetcode;

import ink.lovejinhu.common.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jinhu
 * created 2021-07-01 9:09
 */
public class Solution_0144 {
    public List<Integer> preList = new ArrayList<>();

    /**
     * 根左右
     * 前序遍历
     *
     * @param root
     * @return
     */
    public List<Integer> preorderTraversal(TreeNode root) {
        if (root == null) {
            return preList;
        }
        System.out.println(root.val);
        preList.add(root.val);
        preorderTraversal(root.right);
        preorderTraversal(root.left);
        return preList;
    }
}
